---
hide_table_of_contents: true
---

# Cloudflare Workers AI

If you're deploying your project in a Cloudflare worker, you can use Cloudflare's [built-in Workers AI embeddings](https://developers.cloudflare.com/workers-ai/) with LangChain.js.

## Setup

First, [follow the official docs](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/) to set up your worker.

You'll also need to install the LangChain Cloudflare integration package:

import IntegrationInstallTooltip from "@mdx_components/integration_install_tooltip.mdx";

<IntegrationInstallTooltip></IntegrationInstallTooltip>

```bash npm2yarn
npm install @langchain/cloudflare
```

## Usage

Below is an example worker that uses Workers AI embeddings with a [Cloudflare Vectorize](/docs/integrations/vectorstores/cloudflare_vectorize) vectorstore.

:::note
If running locally, be sure to run wrangler as `npx wrangler dev --remote`!
:::

```toml
name = "langchain-test"
main = "worker.js"
compatibility_date = "2024-01-10"

[[vectorize]]
binding = "VECTORIZE_INDEX"
index_name = "langchain-test"

[ai]
binding = "AI"
```

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/indexes/vector_stores/cloudflare_vectorize/example.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>
